" -- Head
" set leader to space
nnoremap <SPACE> <Nop>
let mapleader = "\<Space>"
let g:python3_host_prog = '/usr/local/bin/python3'
" add support for diffrent languages
filetype plugin indent on
syntax enable
let g:ale_disable_lsp = 1
" -- vim-plug plugins
call plug#begin()
" the status bar plugin
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" highlight and completion
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" nice copilot :)
Plug 'github/copilot.vim'
" git plugin
Plug 'tpope/vim-fugitive'
" themes
Plug 'flazz/vim-colorschemes'
" fuzzy search
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
" lint engine
Plug 'dense-analysis/ale'
" file tree
Plug 'preservim/nerdtree'
Plug 'Xuyuanp/nerdtree-git-plugin'
" write codes more focusly
Plug 'junegunn/goyo.vim'
Plug 'junegunn/limelight.vim'
" rainbow bracket
Plug 'luochen1990/rainbow'
" support more text objects
Plug 'tpope/vim-surround'
call plug#end()
" -- Option settings
colorscheme atom
" hide extra --INSERT--
set cmdheight=1
set noshowmode
" sometimes can remove the !
set hidden
" remove extra backup files
set nobackup
set nowritebackup
" set timeout to make vim-which-key works
set timeout
set timeoutlen=500
" make me easy to view what
" -- Plugin settings
" highlight settings
if has('nvim-0.4.0') || has('patch-8.2.0750')
	nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
	nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
	inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
	inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
	vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
	vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
endif
" coc code actions
xmap <leader>f  <Plug>(coc-format-selected)
nmap <leader>f  <Plug>(coc-format-selected)
xmap <leader>a  <Plug>(coc-codeaction-selected)
nmap <leader>a  <Plug>(coc-codeaction-selected)
nmap <leader>ac  <Plug>(coc-codeaction)
" coc autofix
nmap <leader>qf  <Plug>(coc-fix-current)
nmap <leader>cl  <Plug>(coc-codelens-action)
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
nmap <silent> <C-s> <Plug>(coc-range-select)
xmap <silent> <C-s> <Plug>(coc-range-select)
" coc custom text objects
xmap if <Plug>(coc-funcobj-i)
omap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap af <Plug>(coc-funcobj-a)
xmap ic <Plug>(coc-classobj-i)
omap ic <Plug>(coc-classobj-i)
xmap ac <Plug>(coc-classobj-a)
omap ac <Plug>(coc-classobj-a)
" explorer settings
nmap <leader>e <Cmd>CocCommand explorer<CR>
" status bar settings
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#formatter = 'unique_tail'
let g:airline_theme = 'google_dark'
let g:airline#extensions#coc#enabled = 0
let g:airline#extensions#ale#enabled = 1
" lint settings
let g:ale_linters = {
\    'python': ['pyright']
\}
let g:ale_fixers = {
\    'python': ['autopep8']
\}
" file tree settings
nnoremap <leader>tc :NERDTreeFocus<CR>
nnoremap <leader>t :NERDTree<CR>
nnoremap <leader>tt :NERDTreeToggle<CR>
nnoremap <leader>tf :NERDTreeFind<CR>
" enable rainbow bracket by default
let g:rainbow_active = 1
